//
//  MessageSysterCell.m
//  ProjectXW
//
//  Created by LangLang on 17/6/1.
//  Copyright © 2017年 chirui. All rights reserved.
//

#import "MessageSysterCell.h"

@implementation MessageSysterCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initLayuot];
    }
    return self;
}

-(void)initLayuot{
    _images = [UIImageView new];
    _labelTitles = [UILabel new];
    _times = [UILabel new];
    _contents = [UILabel new];
    _viewf = [UILabel new];
    
    _images.layer.cornerRadius = 16;
    _images.clipsToBounds = YES;
    [self.contentView addSubview:_images];
    [self label:_labelTitles addName:@"" andFont:16 and:strColor(@"333") andCenter:2 andView:self.contentView];
    [self label:_times addName:@"" andFont:13 and:strColor(@"999") andCenter:3 andView:self.contentView];
    [self label:_contents addName:@"" andFont:15 and:strColor(@"666") andCenter:2 andView:self.contentView];
    self.contents.numberOfLines = 0;
    _viewf.backgroundColor = strColor(@"f6f6f6");
    [self.contentView addSubview:_viewf];
    
    [_images mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(@10);
        make.width.height.equalTo(@32);
    }];
    
    [_labelTitles mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@10);
        make.left.equalTo(_images.mas_right).offset(15);
        make.width.equalTo(@200);
        make.height.equalTo(@16);
    }];
    [_times mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(@10);
        make.right.equalTo(@-15);
        make.width.equalTo(@200);
        make.height.equalTo(@16);
    }];
    
    [self.contents mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.images.mas_right).offset(15);
        make.right.lessThanOrEqualTo(@-10);
        make.top.equalTo(_labelTitles.mas_bottom).offset(5);
        make.bottom.equalTo(_viewf.mas_top).offset(-8);
        make.height.greaterThanOrEqualTo(@3);
    }];
    
    [self.viewf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_greaterThanOrEqualTo(10);
        make.height.mas_lessThanOrEqualTo(10);
        make.left.equalTo(@0);
        make.right.mas_equalTo(-0);
        make.bottom.mas_equalTo(-0);
    }];
}

-(void)label:(UILabel *)lableName addName:(NSString *)name andFont:(CGFloat)size and:(UIColor *)color andCenter:(int)intCenter andView:(id)views{
    ![name isKindOfClass:[NSNull class]] ? lableName.text = name : nil;
    lableName.font = [UIFont systemFontOfSize:size];
    lableName.textColor = color;
    switch (intCenter) {
        case 1:
            lableName.textAlignment = NSTextAlignmentCenter;
            break;
        case 2:
            lableName.textAlignment = NSTextAlignmentLeft;
            break;
        case 3:
            lableName.textAlignment = NSTextAlignmentRight;
            break;
        default:
            break;
    }
    [views addSubview:lableName];
}

@end
